package thread.threaddemo;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.LockSupport;

/**
 * @Author: wenjingyuan
 * @Date: 2023/02/11/23:46
 * @Description:
 */
public class ThreadDemo19 {
    public static void main(String[] args) throws InterruptedException {
        Object lock=new Object();
        Thread t1=new Thread(()->{
//            try {
//                Thread.sleep(1000);
//            } catch (InterruptedException e) {
//                e.printStackTrace();
//            }
//            try {
//                TimeUnit.SECONDS.sleep(1000);
//            } catch (InterruptedException e) {
//                e.printStackTrace();
//            }
//            synchronized (lock){
//                try {
//                    lock.wait();
//                } catch (InterruptedException e) {
//                    e.printStackTrace();
//                }
//            }

            Thread currentThread=Thread.currentThread();
            System.out.println("线程的中止状态"+currentThread.isInterrupted());
            LockSupport.park();
            System.out.println("线程的中止状态"+currentThread.isInterrupted());
        });
        t1.start();
        Thread.sleep(1000);
        System.out.println("终止线程");
        t1.interrupt();
       // LockSupport.unpark(t1);
    }
}
